Skip to content

feat(model)!: introduce DeviceTreeNodeRef - #96

Open
m4tx wants to merge 1 commit into
mainfrom
node-trait-1
Open

m4tx wants to merge 1 commit into
mainfrom
node-trait-1

Conversation

@m4tx

@m4tx m4tx commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

This change adds as_read_only method that returns a reference struct pointing to the DeviceTreeNode and removes impl Node for &DeviceTreeNode.

There are two main reasons for making this change:

  • Unifying FdtNodeMut and DeviceTreeNode - since FdtNodeMut contains a mutable reference, it cannot be Copy, so for the Node trait implementation it exposes its own as_read_only method.
  • This allows us to properly store parent_address_space in objects returned by child(), find_node, etc. without any lifetime issues, self-referential structs, mutability problems, or similar.

The main tradeoff is convenience - the users would need to call as_read_only() for every reading operation. To avoid this, convenience wrapper methods are added and unified via a macro shared by FdtNodeMut and DeviceTreeNode.

@m4tx
m4tx requested a review from qwandor October 20, 2026 14:10
@m4tx
m4tx added this pull request to stack #98 October 20, 2026 14:11
This change adds `as_read_only` method that returns a reference struct
pointing to the `DeviceTreeNode` and removes `impl Node for
&DeviceTreeNode`.

There are two main reasons for making this change:
* Unifying `FdtNodeMut` and `DeviceTreeNode` - since `FdtNodeMut`
  contains a mutable reference, it cannot be `Copy`, so for
  the `Node` trait implementation it exposes its own `as_read_only`
  method.
* This allows us to properly store `parent_address_space` in objects
  returned by `child()`, `find_node`, etc. without any lifetime issues,
  self-referential structs, mutability problems, or similar.

The main tradeoff is convenience - the users would need to call
`as_read_only()` for every reading operation. To avoid this, convenience
wrapper methods are added and unified via a macro shared by `FdtNodeMut`
and `DeviceTreeNode`.
@codecov

codecov Bot commented Oct 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.16129% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.38%. Comparing base (40eb29c) to head (8e85c6e).

Files with missing lines Patch % Lines
src/util.rs 83.33% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #96      +/-   ##
==========================================
+ Coverage   93.16%   93.38%   +0.22%     
==========================================
  Files          26       26              
  Lines        3336     3358      +22     
==========================================
+ Hits         3108     3136      +28     
+ Misses        228      222       -6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant